clear;close all;clc;

% we read in our single-source recordings to create our own models at 4
% frequencies.

% freqs = 100:100:3000
% nturns=[0.1 0.4 0.8 0.7 0.8 1.2 1.3 1.4 1.8 2.2];
% rad=0.2;
% rad=0.1;
% Norder=2;
% thre = 0.0;

% Num_centers = 1;
% Proto_Num = 1.2;
% Proto_Num = 21;
Proto_Num = 32;
% Proto_Num = 2;

if Proto_Num==32
% onsets=[13.5 13 13.5 12.5 13 12.5 12.5 12.5 13 12 ...
%         12    12 13   12   8 14    12  12  16.5 13] % 1st recording

onsets = [14 18.5 12.5 15 12.5 21.5 13 12.5 12 12.5 ...
    12 12.5 12.5 12.5 13 12 12 12 12]
elseif   Proto_Num==2 % male speech single
    onsets = [14 18.5 12.5 15 12.5 21.5 13 12.5 12 12.5 ...
    12 12.5 12.5 12.5 13 12 12 12 12]
end
% tdur=0.02; % formal
% tdur=0.04; % formal
% tdur=0.08; % formal
% tdur=1; % formal

% freqs= [291 600 1500 3000]; %just a random frequency
% freqs= [300 600 850 900 1000 2000]; %just a random frequency
% freqs= [ 850 900 1000]; %just a random frequency
% nturns = [0.98 1.09 1.13];
% freqs= [  910]; %just a random frequency
% nturns = [ 1.13];
% fs = 44100;
% whos
% plot_each =1;

Angles = -90:10:90;
sides = {'Left','Right'};


% f2=figure('position',[100 70 800 500]);

for iangle = 1:length(Angles)
    % figure(f1)
    % subplot(5,6,iangle);
    % cc = 0;
    Angle = Angles(iangle);
    PString = num2str(Proto_Num);
    if Angle < 0
        ss = '-';
    else
        ss = '+';
    end
    [recorded_sound fs2]=audioread(['C:\Users\gaiy\OneDrive - Saint Louis University\Sound_loc\3Dio recordings\Protocol_' PString '_deg' ss num2str(abs(Angles(iangle))) '.mp3']);
    % recorded_sound=resample(YY,441,320);
    % recorded_sound=YY;
    % beginP = (ifreql-1).*20.*fs+1;
    % endP = ifreql.*20.*fs;

    figure('position',[100 70 1600 700]);
    NL = length(recorded_sound(:,1));
    tsig = (1:NL)./fs2;
    plot(tsig,recorded_sound(:,1))
    xlabel('Time (sec)')
    % xlim([10 30]);
    grid on;
    % pause
end

